package com.pisolution.actuator.service.util;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

/**
 * @author likai
 * @version 1.0.0
 * @ClassName HttpUtil.java
 * @Description TODO
 * @createTime 2021年09月15日 15:52:00
 */
public class HttpUtil {

    //连接超时时间
    private static final long CONNECTION_TIME_OUT = 5 * 1000;

    //读取超时时间
    private static final long READ_TIME_OUT = 10 * 1000;

    /**
     * @title
     * @description
     * @author admin
     * @updateTime 2021/9/15 15:59
     * @throws
     */
    public static RestTemplate buildRT(){
        RestTemplateBuilder builder = new RestTemplateBuilder()
            .setConnectTimeout(Duration.ofMillis(CONNECTION_TIME_OUT))
            .setReadTimeout(Duration.ofMillis(READ_TIME_OUT));
        return builder.build();
    }
}
